<template>
  <el-scrollbar class="tabs">
    <div
      :class="['li', { active: item.bulletionType === acitiveId }]"
      v-for="(item, index) in dataList"
      :key="index"
      @click="change(item.bulletionType)">
      <div class="tit">
        <div class="tit-type">{{ item.bulletionTypeName }}</div>
        <div class="tit-time">{{ item.showDate }}</div>
      </div>
      <div class="tip">
        <div class="tip-label">{{ item.bulletinTypeDetail }}</div>
        <div class="num" v-if="item.unReadNum * 1 > 0">
          <el-badge :value="item.unReadNum * 1" :max="99" class="item"></el-badge>
        </div>
      </div>
    </div>
  </el-scrollbar>
</template>

<script>
import { selectAllBulletinNumByType } from '@apis/message.js'
export default {
  name: 'TabsList',
  components: {},
  props: {},
  data() {
    return {
      dataList: [
        // { title: '纪实通知', type: '周纪实、月小结、季总结完成通知', time: '2021-11-15', num: '3', bulletionType: 0 },
        // { title: '评议通知', type: '月度评价、季度评价通知', time: '2021-11-02', num: '3', bulletionType: 1 },
        // { title: '加减分通知', type: '加减分项录入通知', time: '2021-11-15', num: '3', bulletionType: 2 },
        // { title: '系统公告', type: '系统公告消息', time: '2021-11-15', num: '3', bulletionType: 3 },
        // { title: '用户通知', type: '各单位人员变动通知', time: '2021-11-15', num: '100', bulletionType: 4 },
      ],
      acitiveId: 0,
    }
  },
  computed: {},
  watch: {},
  created() {
    this.getPageDataList()
  },
  mounted() {},
  methods: {
    change(bulletionType) {
      if (bulletionType === this.acitiveId) return
      this.acitiveId = bulletionType
      this.emitChange()
    },

    async getPageDataList() {
      const { data } = await selectAllBulletinNumByType()
      this.dataList = data
      this.acitiveId = this.dataList[0].bulletionType
      this.emitChange()
    },
    emitChange() {
      this.$emit('change', this.acitiveId)
    },
    async reviewData(type) {
      const { data } = await selectAllBulletinNumByType()
      this.dataList = data
      this.acitiveId = type
    },
  },
}
</script>

<style lang="scss" scoped>
.tabs {
  font-size: 14px;
  width: 100%;
  height: 100%;
  box-shadow: 0px 0px 15px 0px rgba(2, 2, 2, 0.22);

  .li {
    cursor: pointer;
    width: 100%;
    border-bottom: 1px solid #ccc;
    padding: 15px 20px;
    .tit {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-bottom: 10px;
      &-type {
        font-weight: 600;
        color: #333;
      }
      &-time {
        color: #666;
      }
    }
    .tip {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 12px;
      color: #777;
    }
    &.active {
      background-color: #5a96e9;
      .tit {
        color: #ffffff;
        &-type {
          color: #ffffff;
        }
        &-time {
          color: #ffffff;
        }
      }
      .tip {
        color: #ffffff;
      }
    }
    &:hover {
      background: #5a96e9;
      opacity: 0.8;
      .tit {
        color: #ffffff;
        &-type {
          color: #ffffff;
        }
        &-time {
          color: #ffffff;
        }
      }
      .tip {
        color: #ffffff;
      }
    }
  }
}
</style>
